package com.aiit.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.*;

@Configuration
@EnableWebMvc//如果标注了就会被springmvc全面接管
public class WebAppConfigurer implements WebMvcConfigurer {
 //        解决静态资源被拦截
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry){

        registry.addResourceHandler("swagger-ui.html").addResourceLocations(
                "classpath:/META-INF/resources/");
//        registry.addResourceHandler("/webjars/**").addResourceLocations(
//                "classpath:/META-INF/resources/webjars/");

        registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
        registry.addResourceHandler("/**").addResourceLocations("classpath:/static/");
//        registry.addResourceHandler("/**").addResourceLocations("classpath:/");
    }
    @Override
    public void addViewControllers(ViewControllerRegistry registry){
//        前端主页控制实现，可以加载样式
        registry.addViewController("/").setViewName("main");
        registry.addViewController("/main.html").setViewName("main");
        registry.addViewController("/login2.html").setViewName("main");
    }
}
